package library;

public	class UnionFind{
	int rep;
	boolean isEnd;
	UnionFind next, head,end;

	public UnionFind(Object here,int rep){
		this.rep = rep;
		head=this;
		end=this;
		isEnd=true;
	}
	public boolean find(UnionFind o){
		return rep==o.rep;
	}
	public void union(UnionFind other){
		end.next=other.head;
		end.isEnd=false;
		
		UnionFind te = other.end;
		UnionFind current = head;
		do {
			current.head=head;
			current.end=te;
			current.rep=rep;
		}while (!current.isEnd);
		
		end.isEnd=false;
	}
}
